<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="s" value="${sessionScope.member.custNickname }"/>
<c:set var="a" value="${sessionScope.member.custName }"/>
<c:set var="c" value="${requestScope.board.writer }"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>글내용</title>
<style type="text/css">
div{
	width:600px;
 	padding: 5px;
 	border-left:1px solid gray;
 	border-right:1px solid gray;
 	border-bottom:1px solid gray;
 	
}
#title{
font-weight: bold;
border-top:1px solid gray;
}
#info{
font-size: 13px;
}
#content{
min-height:300px; 
height:auto;
}
</style>

 


</head>
<script type="text/javascript" src="/tour/js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("#reply").on("click", function(){
		$.ajax({
			"url":"/tour/ep_board/reply.do",//요청 url
			"data":{"num":$("#num").val() , "reply":$("#troll").val() ,"writer":$("#rewriter").val()},//요청파라미터
			"type":"post",//요청방식
			"dataType":"json",//응답 데이터의 타입
			"beforeSend":function(){
				if(!$("#troll").val()){
						alert("댓글을 입력하세요");
					}
				},
			"success":function(data){
				$("#reply_result").empty()
				$.each(data, function(){
				$("#reply_result").append($("<tr>")
									.append($("<td>").text(this.reEpWriter))
									.append($("<td>").text(this.reEpContent))
									.append($("<td>").text(this.reEpWritedate)));
					});
				}
			});
			$("#recommend").on("click", function(){
				$.ajax({
					"url":"/tour/ep_board/recommend.do",//요청 url
					"data":{"boardNo": ${requestScope.board.no} ,"id" : '${sessionScope.member.custId}' ,"boardName" : 'ep_board'   },//요청파라미터
					"type":"post",//요청방식
					"dataType":"json",//응답 데이터의 타입
					"success":function(data){
						alert(data)
							
						}
			});
		});
	});
});

$(document).ready(function(){
	$("#recommend").on("click", function(){
		$.ajax({
			"url":"/tour/ep_board/recommend.do",//요청 url
			"data":{"boardNo": ${requestScope.board.no} ,"id" : '${sessionScope.member.custId}' ,"boardName" : 'ep_board'   },//요청파라미터
			"type":"post",//요청방식
			"dataType":"json",//응답 데이터의 타입
			"success":function(data){
				alert(data)
					
				}
			});
		
			
		});
	
});
</script>
<body >
<hr>
<div id="title">
${requestScope.board.no }.${requestScope.board.title }
</div>
<div id="info">
작성자 : ${requestScope.board.writer } | 조회수 : ${ requestScope.board.viewcount} | 작성일시 : ${requestScope.board.writedate} | 추천수 : ${ requestScope.board.recommendcount} | <input type="button" id="recommend" value="추천">
</div>
<div id="content">
<img src="/tour/ep_img/${requestScope.board.img }" width="300px" height="200px"><p>
${requestScope.board.content }
</div>
<p><p>
<c:if test="${a!=null }">
<form action="">
	<input type="hidden" name="num" id="num" value="${requestScope.board.no }">
	<input type="hidden" name="rewriter" id="rewriter" value="${sessionScope.member.custNickname }">	
	<table>
		<tr>
			<td>댓글 : </td><td><textarea cols="50" rows="5" name="troll" id="troll"></textarea></td>
			<td><input type="button" value="등록" id="reply" ></td>
		<tr>
	</table>
</form>
</c:if>

<table border="1" cellspacing="0">
<thead>
<tr><th width="100">ID</th><th width="350">댓글</th><th width="150">날짜</th></tr>
</thead>
<tbody id="reply_result">
<c:forEach items="${requestScope.re }" var="rep">
	<tr>
		<td>${rep.reEpWriter }</td><td>${rep.reEpContent }</td><td>${rep.reEpWritedate }</td>
	</tr>
</c:forEach>
</tbody>
</table>
<p>
<a href="/tour/ep_board/list.do?page=${param.page }">글목록</a>&nbsp;&nbsp;
<c:if test="${c==s || a=='관리자'}">

<a href="/tour/ep_board/deleteContent.do?no=${requestScope.board.no }&page=${param.page }">글 삭제</a>&nbsp;&nbsp;
</c:if>
</p>
</body>
</html>














